scrapbox to speech
音声読み上げ
TODO:
plain textを渡すか(たぶんAPIあるよな)、正規表現でPlain Textにする。
code:script.js
// 選択した文章に対してボタンを追加
scrapbox.PopupMenu.addButton({
title: 'Speach',
// ボタンをクリックして選択した文章の内容を取得(Plain textで取得するのが望ましい)
onClick: text => {
// こちらを参考にWeb Speech APIを使う
text = text.replace(/>/g, '');
//alert(text);
const uttr = new SpeechSynthesisUtterance(text);
if (speechSynthesis.speaking == false) {
speechSynthesis.speak(uttr);
} else {
speechSynthesis.cancel();
}
}
})
下記のように自分のページで code:script.js のコードブロックの中でimportすれば使えます。
code:import_example
import '/api/code/wordbook/scrapbox_to_speech/script.js'